<?php
namespace Admin\Model;
use Think\Model\MongoModel;
Class BookModel extends MongoModel {
	Protected $pk = '_id';
	Protected $_idType = self::TYPE_OBJECT;
	protected $tableName = 'book';
	
	public function get_count()
	{
		return M('book')->count();
	}
	
	public function get_book_list()
	{
		return M('book')->order("_id desc")->select();
	}
	
	public function add_book($data)
	{
		return M('book')->add($data);
	}
	
	public function edit_book($id,$data)
	{
		$MongoId = new \MongoId($id);
		return M('book')->where(array('_id'=>$MongoId))->save($data);
	}
	
	public function del_book($id)
	{
		$MongoId = new \MongoId($id);
		return M('book')->where(array('_id'=>$MongoId))->delete();
	}
	
	public function find_book($id)
	{
		$MongoId = new \MongoId($id);
		$res = M('book')->where(array('_id'=>$MongoId))->select();
		//echo  M('book')->getLastSql(); 
		return $res;
	}
	
	
}